home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9662 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: news1.h1.usa.pipeline.com!usenet
  2. From: grantp@usa.pipeline.com(Pete)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: C code in a C++ app
  5. Date: 3 Mar 1996 12:03:05 GMT
  6. Organization: Kalevi, Inc.
  7. Message-ID: <4hc1pp$1eu@news1.usa.pipeline.com>
  8. References: <4hbddg$899@sam.inforamp.net>
  9. NNTP-Posting-Host: pipe9.h1.usa.pipeline.com
  10. X-PipeUser: grantp
  11. X-PipeHub: usa.pipeline.com
  12. X-PipeGCOS: (Pete)
  13. X-Newsreader: Pipeline v3.5.0
  14.  
  15. On Mar 03, 1996 06:15:22 in article <Re: C code in a C++ app>,
  16. 'rmorin@inforamp.net (Randy Charles Morin)' wrote: 
  17.  
  18.  
  19. >In article <4h7t43$6as@frodo.smartlink.net>, 
  20. >thomash@warp10.smartlink.net (Thomas Hackbarth) wrote: 
  21. >>I'm working on porting a C app. from MAC to the PC. The app is basicly C 
  22.  
  23. >>and I'm replacing the UI for the PC side. I need to compile and link C  
  24. >>code into my MFC application. I get errors basicly saying I can't compile
  25.  
  26. >>C code with CPP, OK I renamed the file to CPP then I need to add #include
  27.  
  28. >><stdafx.h>. I would rather not change any of the C files at all. They  
  29. >>need to stay multiplatform as well as multi-compiler.  
  30. >> 
  31. >>Does anyone know how to build a MCF app with C code, with out changing  
  32. >>the C code. 
  33. >Change your function headers to 
  34. >    extern "C" void _export PayrollProcess(PAYROLLPROCESS * B) 
  35. >from 
  36. >    void _export PayrollProcess(PAYROLLPROCESS * B) 
  37. >This tells the compiler that your C++ code is really C code. 
  38. Unfortunately, this answer is not to the question asked.  (Aside from 
  39. possibly being wrong).  The _export keyword is not used in MSVC++4.0, 
  40. which, if I remember correctly, was specified in the original post.  But 
  41. it's a moot point since it is used only in DLLs, which is not the subject 
  42. of the question. 
  43.  
  44. The correct answer is to leave the C code with extension .c, omit the 
  45. inclusion of <stdafx.h>, and change the compiler option switches  
  46. pertaining to precompiled headers.  The use of extern "C", of course, is 
  47. appropriate.  
  48.  
  49. -- 
  50. Pete Grant 
  51. Kalevi, Inc. 
  52. Software Engineering & development
  53.